using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace AcceleratorSearch
{
    public partial class FormMain : DevComponents.DotNetBar.Metro.MetroForm
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            listResult.VirtualMode = true;
            listResult.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(listView_RetrieveVirtualItem);
            SearchCore.Init(this);
        }

        private void listView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            if (SearchCore.Searcher == null || SearchCore.Searcher.Count == 0)
            {
                return;
            }
            e.Item = SearchCore.CreateListViewItemFromNode(SearchCore.Searcher, e.ItemIndex);
            //if (SearchCore.CurrentCacheItemsSource == null || SearchCore.CurrentCacheItemsSource.Count == 0)
            //{
            //    return;
            //}

            //e.Item = SearchCore.CurrentCacheItemsSource[e.ItemIndex];
            //if (e.ItemIndex == SearchCore.CurrentCacheItemsSource.Count)
            //{
            //    SearchCore.CurrentCacheItemsSource = null;
            //}
        }
    }
}